<template>
    <div>
        <van-nav-bar title="搜索" left-arrow @click-left="($router.push('/home/index'))" />
        <van-search v-model="value" placeholder="请输入搜索关键词" />
        <div v-for="item in search">
            <router-link :to="{ name: 'detail', params: { goods_id: item.goods_id } }">
                <van-cell-group>
                    <van-cell :title="item.goods_name" />
                </van-cell-group>

            </router-link>

        </div>

    </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import { searchApi } from '@/api/api';
import _ from 'lodash'
let search = ref([])
let value = ref('')
watch(value,
    _.debounce((val) => {
        searchApi(val).then(res => {
            console.log('搜索', res)
            search.value = res.data.message.goods
        })
    }, 1000))



</script>

<style lang="scss" scoped></style>